
<style lang="scss" scoped>
	.content {
		width: 750rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		margin-bottom: 100rpx;
	}
	.box{
		height: 260rpx;
		width:100%;
		
	}
</style>
<template>
	<view class="content">
		
		<view class="box" v-for="(item,index) in list" :key="index">
			<delSlideLeft :data_transit="{index:index,item:item}" @delItem="delItem(item,index)">
				<list :item="item"></list>

			</delSlideLeft>
		</view>
		<view class="center-flex c999 f24" v-if="nomore">-没有更多了-</view>
		<view v-if="empty" style="position: fixed;top:40%;left:50%;transform: translateX(-50%);">
			<u-empty text="暂无列表"></u-empty>
		
		</view>
	</view>
</template>

<script>
	import list from '@/components/goodslist.vue'
	import delSlideLeft from '@/components/ay-operate/del_slideLeft.vue'
	export default {
		components: {
			delSlideLeft,
			list
		},
		data() {
			return {
				page: 1,
				list: [],
				nomore: false,
				empty: false,
			}
		},
		onLoad() {
			this.reset()
		},
		onReachBottom() {
			if(!this.nomore){
				this.page++
				this.getlist()
			}
		},
		methods: {
			reset() {
				this.$showloading()
				this.page = 1
				this.list = []
				this.nomore = false
				this.getlist()
			},
			getlist() {
			
				this.$pop.ajaxPost('/api/person/collect', {
					
					page: this.page,
					size: 10
				}).then(res => {
					uni.hideLoading()
					var list = res.data
					
					this.list= this.list.concat(list)
								
					if (this.list.length == 0) {
						this.empty = true
					} else {
						this.empty = false
						if (list.length < 10) {
							this.nomore = true
						} else {
							this.nomore = false
						}
					}
					// console.log(this.list)
				})
			},
			delItem(item,index){
				this.$pop.ajaxGet('/api/index/collect', {
					id: item.id
				}).then(res=>{
					this.list.splice(index,1)
					
				})
			}
		}
	}
</script>
